package com.nbsaas.boot.product.data.entity;

import com.nbsaas.boot.code.annotation.*;
import com.nbsaas.boot.code.annotation.data.Dict;
import com.nbsaas.boot.code.annotation.data.DictItem;
import com.nbsaas.boot.jpa.data.entity.AbstractEntity;
import com.nbsaas.boot.jpa.data.entity.User;
import jakarta.persistence.*;
import lombok.Data;
import org.hibernate.annotations.Comment;

/**
 * 商品品牌实体
 */
@Comment("商品品牌表")
@CreateByUser
@ComposeView
@Data
@FormAnnotation(title = "商品品牌", model = "品牌", searchWidth = "100", viewWidth = "120")
@Entity
@Table(name = "nb_product_brand")
public class Brand extends AbstractEntity {

    @Comment("品牌名称")
    @SearchItem(name = "name", key = "name", label = "品牌名称")
    @FormField(title = "品牌名称", sortNum = "1", grid = true, required = true)
    @Column(length = 50)
    private String name;

    @Comment("品牌编号")
    @SearchItem(name = "code", key = "code", label = "品牌编号")
    @FormField(title = "品牌编号", sortNum = "2", grid = true)
    @Column(length = 30)
    private String code;

    @Comment("品牌LOGO")
    @FormField(title = "品牌LOGO", sortNum = "3", grid = true, type = InputType.image)
    @Column(length = 300)
    private String logo;

    @Comment("品牌国家")
    @FormField(title = "品牌国家", sortNum = "4", grid = true)
    @Column(length = 50)
    private String country;

    @Comment("品牌网址")
    @FormField(title = "品牌网址", sortNum = "6", grid = true)
    @Column(length = 200)
    private String url;


    @Comment("品牌描述")
    @FormField(title = "品牌描述", sortNum = "5", type = InputType.textarea, col = 23)
    private String note;

    @Comment("排序号")
    @FormField(title = "排序号", sortNum = "6", grid = true, type = InputType.el_input_number, sort = true)
    private Integer sortNum;

    @Dict(
            items = {
                    @DictItem(value = -1, label = "禁用"),
                    @DictItem(value = 1, label = "启用")
            }
    )
    @Comment("启用状态")
    @FormField(title = "启用状态", sortNum = "7", grid = true)
    private Integer state;

    @Comment("创建人")
    @JoinColumn
    @FieldConvert
    @FieldName
    @ManyToOne(fetch = FetchType.LAZY)
    private User creator;


}
